# Maintainer: Morten Linderud <foxboron@archlinux.org>

pkgname=gopass
pkgver=1.15.10
pkgrel=1
pkgdesc="The slightly more awesome standard unix password manager for teams."
arch=('loong64' 'x86_64')
url="https://github.com/gopasspw/gopass"
license=('MIT')
makedepends=('go')
optdepends=('xdotool: for typing passwords selected by dmenu'
            'xsel: clipboard support'
            'xclip: clipboard support'
            'wl-clipboard: clipboard support (wayland)')
options=("!lto")
source=("https://github.com/gopasspw/gopass/releases/download/v${pkgver}/gopass-${pkgver}.tar.gz")
sha512sums=('7f6425795a6a1ed4fd05132f369f53a8781496bf70b20a14df54424332e0e998a6e4f163280ca009bec82caa681483576ee6bfba01fc7ff93e95bbe89db4eb67')

prepare(){
  sed -i 's|-gcflags="-trimpath=$(GOPATH)" -asmflags="-trimpath=$(GOPATH)"||' Makefile
}

build(){
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
  make 
}

package() {
  make DESTDIR="${pkgdir}" PREFIX="/usr" install
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
